import static
from common.utils.read_file import read_yaml, read_ini


class EnvConfig:
    config = None

    @classmethod
    def get_config(cls):
        if EnvConfig.config:
            return EnvConfig.config
        else:
            environ = IniConfig.get_env()
            config_path = static.env[environ].config_path
            config = read_yaml(config_path)
            return config


class IniConfig:
    conf = None

    @classmethod
    def get_config(cls):
        if IniConfig.conf:
            conf = IniConfig.conf
        else:
            conf = read_ini()
        return conf

    @classmethod
    def get_env(cls):
        conf = IniConfig.get_config()
        env = conf.get('pytest', 'env')
        return env


if __name__ == '__main__':
    config = EnvConfig.get_config()
    print(config)